package com.panopset.sf.apps.blackjack;

import java.awt.Component;

import javax.swing.JComponent;
import javax.swing.JTabbedPane;

import com.panopset.game.blackjack.BlackjackGame;
import com.panopset.sf.FontManager;
import com.panopset.sf.Windoc;

/**
 *
 * @author Karl Dinwiddie
 *
 */
public class BlackjackSwingPanel {

    private final BlackjackGame m;
    private final Windoc w;

    JComponent p;

    final Component gp;

    public BlackjackSwingPanel(Windoc windoc, BlackjackGame game,
            final Component component) {
        w = windoc;
        m = game;
        gp = component;
    }

    private Felt felt;

    public Felt getFelt() {
        if (felt == null) {
            felt = new Felt(w, m);
        }
        return felt;
    }

    private JTabbedPane frontPane;

    public JTabbedPane getFrontPane() {
        if (frontPane == null) {
            frontPane = new JTabbedPane();
            FontManager.getInstance().register(frontPane,
                    FontManager.FontType.boldArial);
        }
        return frontPane;
    }

    public JComponent getPanel() {
        if (p == null) {
            p = getFrontPane();
            p.add(getFelt().getPanel());
            p.add(gp);
        }
        return p;
    }
}
